#include "kernel/types.h"
#include "kernel/stat.h"
#include "user/user.h"

int main(int argc, char *argv[]) {
    int fd[2];
    char buf[16];
    pipe(fd);

    int pid = fork();
    if (pid == 0) {
        printf("son process\n");
        read(fd[0], buf, 16);
        printf("son process received %s\n", buf);
        write(fd[1], "pong2", 16);
    } else {
        printf("parent process\n");
        write(fd[1], "ping1", 16);
        wait(0);
        read(fd[0], buf, 16);
        printf("parent process received %s\n", buf);
    }
    exit(0);
}

 

